#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi: ts=4 expandtab
#
# Copyright (C) 2012 KT
#
# Author: Choonho Son <choonho.son@kt.com>
#

__version__="1.0"

import sys

class Cmd:
	"""
	default class
	"""
	def __init__(self, logger):
		self.logger = logger

	def run(self, cmd):
		import subprocess
		import traceback
		try:
			proc = subprocess.Popen(cmd)
			out,err = proc.communicate()
			self.logger.debug("OUT:%s" % out)
			self.logger.debug("ERR:%s" % err)
			return (out,err)

		except:
			self.logger.debug(traceback.format_exc())
			sys.exit()
			#raise Exception("Cmd failed %s" % cmd)
		
		
	def isExist(self, path):
		pass

	def service(self, svc, action='restart'):
		"""
		start service daemon
		@param svc : service name
		"""
		cmd = ["service",svc,action]
		(out,err) = self.run(cmd)

		
